repo = registry.cn-shanghai.aliyuncs.com/toolkite/flow-steps
vers = 5.6.40 7.4.33 8.2.29

cri := $(shell command -v podman || command -v docker)

all: $(addsuffix -cli-alpine,$(vers))

%-cli-alpine: Dockerfile
	$(cri) build --tag $(repo):php-$@ --build-arg=PHP_TAG=$@ .

%-cli-alpine.test: %-cli-alpine
	$(cri) run --rm -w /root/workspace --entrypoint=/bin/bash -it $(repo):php-$< -c pwd

test: $(addsuffix -cli-alpine.test,$(vers))

%-cli-alpine.deploy: %-cli-alpine
	$(cri) push $(repo):php-$<

deploy: $(addsuffix -cli-alpine.deploy,$(vers))

clean:
	$(cri) rmi -f $(addprefix $(repo):php-,$(addsuffix -cli-alpine,$(vers)))
